package com.jerry.template.module.mainpage.shouye.fragment;

import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.jerry.template.R;
import com.jerry.template.base.BaseFragment;
import com.jerry.template.module.mainpage.shouye.adapter.HomePageFragmentAdapter;
import com.jerry.template.module.mainpage.shouye.duanzi.fragment.EasyJokeFragment;
import com.jerry.template.module.mainpage.shouye.game.fragment.GameFragment;
import com.jerry.template.module.mainpage.shouye.image.fragment.ImageFragment;
import com.jerry.template.module.mainpage.shouye.jinghua.fragment.EssenceFragment;
import com.jerry.template.module.mainpage.shouye.localcity.fragment.LocalCityFragment;
import com.jerry.template.module.mainpage.shouye.video.fragment.VideoFragment;
import com.jerry.template.module.mianpage.shouye.recommend.home.fragment.RecommendFragment;
import com.jerry.template.views.SlidingTabLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by chenhuan on 2016/5/11.
 */
public class HomePageDefaultFragment extends BaseFragment{

    @BindView(R.id.tab)
    SlidingTabLayout tabLayout;
    @BindView(R.id.VP_content)
    ViewPager viewPager;

    public HomePageDefaultFragment(){
    }

    private List<Fragment> mFragment ;
    private HomePageFragmentAdapter adapter;
    @Override
    protected int getLayoutId(){
        return R.layout.frag_default;
    }

    @Override
    protected void initViews(){
        intiFragment();

        adapter = new HomePageFragmentAdapter(getChildFragmentManager(),mFragment);

        viewPager.setAdapter(adapter);

        //设置tab间隔线的颜色
        //tabLayout.setDividerColors(Color.argb(0, 0, 0, 0));

        //自定义tab的布局
        tabLayout.setCustomTabView(R.layout.tab_view, R.id.tabText);
        //设置滚动条颜色
        tabLayout.setSelectedIndicatorColors(Color.argb(255, 0x59, 0xA9, 0xFF));
        tabLayout.setViewPager(viewPager);
    }

    @Override
    protected void loadData(){
    }

    private void intiFragment(){
        mFragment = new ArrayList<>();
        Fragment fragment = null;

        //推荐
        fragment = BaseFragment.newInstance(RecommendFragment.class,null );
        mFragment.add(fragment);
        //视频
        fragment = BaseFragment.newInstance(VideoFragment.class,null);
        mFragment.add(fragment);

        //图片
        fragment = BaseFragment.newInstance(ImageFragment.class, null);
        mFragment.add(fragment);
        //段子
        fragment = BaseFragment.newInstance(EasyJokeFragment.class, null);
        mFragment.add(fragment);

        //精华
        fragment = BaseFragment.newInstance(EssenceFragment.class,null);
        mFragment.add(fragment);
        //同城
        fragment = BaseFragment.newInstance(LocalCityFragment.class,null);
        mFragment.add(fragment);

        //游戏
        fragment = BaseFragment.newInstance(GameFragment.class,null);
        mFragment.add(fragment);
    }
}
